//
//  ShareDeviceHeaderView.m
//  jingdongfang
//
//  Created by mac on 16/9/8.
//  Copyright © 2016年 ZhiYu Hao. All rights reserved.
//

#import "ShareDeviceHeaderView.h"

@implementation ShareDeviceHeaderView

+ (ShareDeviceHeaderView *)shareDeviceHeaderViewAddressBlock:(AddressBlock)addressBlock {
    ShareDeviceHeaderView *item = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:self options:nil] lastObject];
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    item.textField.leftView = view1;
    item.textField.leftViewMode = UITextFieldViewModeAlways;

    UIImageView *leftView = [[UIImageView alloc] init];
    leftView.image = [UIImage imageNamed:@"app_search_icon"];
    [view1 addSubview:leftView];
    
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(item.textField.width - 40, 0, 40, 40)];
    item.textField.rightView = view2;
    item.textField.rightViewMode = UITextFieldViewModeAlways;
    
    UIImageView *rightView = [[UIImageView alloc] init];
    rightView.userInteractionEnabled = YES;
    rightView.image = [UIImage imageNamed:@"iGallery_Share_AddressBook"];
    [view2 addSubview:rightView];
    
    [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(10);
        make.width.height.mas_equalTo(20);
    }];
    
    [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(10);
        make.width.height.mas_equalTo(20);
    }];
    
    [rightView setTapActionWithBlock:^{
        if (addressBlock) {
            addressBlock();
        }
    }];

    return item;
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
